package com.itheima.controller;

import com.itheima.common.R;
import com.itheima.domain.OmsMoneyInfoParam;
import com.itheima.domain.OmsOrder;
import com.itheima.manager.OmsOrderManager;
import com.itheima.vo.OmsOrderVo;
import com.itheima.vo.OmsReceiverInfoParam;
import com.itheima.vo.PageBeanVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
public class OmsOrderController {

    @Autowired
    OmsOrderManager omsOrderManager;

    @PostMapping("/order/delete")
    public R orderDelete(@RequestParam Integer[] ids){
        return omsOrderManager.orderDelete(ids);
    }


    @GetMapping("/order/list")
    public R<PageBeanVo> findOrderList(@RequestParam(required = false) String createTime,
                                       @RequestParam(required = false) String orderSn,
                                       @RequestParam(required = false) Integer orderType,
                                       @RequestParam Integer pageNum,
                                       @RequestParam Integer pageSize,
                                       @RequestParam(required = false) String receiverKeyword,
                                       @RequestParam(required = false) Integer sourceType,
                                       @RequestParam(required = false) Integer status){
        return omsOrderManager.findOrderList(createTime,orderSn,orderType,pageNum,pageSize,receiverKeyword,sourceType,status);
    }

    @PostMapping("/order/update/close")
    public R orderClose(@RequestParam Integer[] ids,
                        @RequestParam String note){
        return omsOrderManager.orderClose(ids,note);
    }

    @PostMapping("/order/update/delivery")
    public R orderSend(@RequestBody List<OmsOrderVo> deliveryParamList){

        return omsOrderManager.orderSend(deliveryParamList);
    }

    @GetMapping("/order/{id}")
    public R orderFindById(@PathVariable Integer id){
        return omsOrderManager.orderFindById(id);
    }

    @PostMapping("/order/update/note")
    public R orderNote(@RequestParam Integer id,
                       @RequestParam String note,
                       @RequestParam Integer status){
        return omsOrderManager.orderNote(id,note,status);
    }

    @PostMapping("/order/update/receiverInfo")
    public R orderUpdatePeopel(@RequestBody OmsReceiverInfoParam receiverInfoParam){
        return omsOrderManager.orderUpdatePeopel(receiverInfoParam);
    }

    @PostMapping("/order/update/moneyInfo")
    public R orderUpdateMoney(@RequestBody OmsMoneyInfoParam moneyInfoParam){
        return omsOrderManager.orderUpdateMoney(moneyInfoParam);
    }
}

